<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function f(){
				console.log(`从键盘输入${event.key},键值是${event.keyCode}`);
				if(event.keyCode<65||event.keyCode>122||(event.keyCode>90&&event.keyCode<97)){
					console.error("只能输入字母!")
					event.preventDefault()
				}
			}
		</script>
	</head>
	<body>
		请输入字母:<input type="text"  id="num" onkeypress="f()"/>
		
	</body>
</html>
